#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <cstdio>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;
using ui = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
static constexpr int MAX_NODE =  5050;


int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int x = 0, index = 0, max_val = 1;
    vector<int> a(100005, 0);
    while (cin >> x) a[++index] = x;

    vector<int> b(100005, 0);
    b[1] = INT_MAX - 10;
    int index_b = 1;
    
    vector<int> dp(100005, 0);
    dp[1] = a[1];
    int index_dp = 1;
    for (int i = 2; i <= index; i++)
    {
        if (dp[index_dp] >= a[i]) dp[++index_dp] = a[i];
        else *upper_bound(dp.begin() + 1, dp.begin() + 1 + index_dp, a[i], greater<int>()) = a[i];
    }
    cout << index_dp << endl;

    // O(n²)
    // vector<int> dp(100005, 1);
    // for (int i = 1; i <= index; i++)
    // {
    //     for (int j = 1; j < i; j++)
    //         if (a[j] >= a[i])
    //             dp[i] = max(dp[i], dp[j] + 1);
    //     max_val = max(max_val, dp[i]);
    // } cout << max_val << endl;

    for (int i = 1; i <= index; i++)
    {
        if (b[index_b] < a[i]) b[++index_b] = a[i];
        else *lower_bound(b.begin() + 1, b.begin() + 1 + index_b, a[i]) = a[i];
    } cout << index_b;



    return 0;
}














